package Math;

import java.util.Scanner;

public class APIMathdem02 {
    public static void main(String[] args) {
        //判断一个数是否是素数
        System.out.println("请输入一个数");
        Scanner sc = new Scanner(System.in);
        int number = sc.nextInt();

        boolean ret = isprime(number);
        if (ret) {
            System.out.println(number + "是素数");
        } else {
            System.out.println(number + "不是素数");
        }
    }

    private static boolean isprime(int num) {
        if (num <= 1) {
            return false;
        }
        int i = 0;
        for (i = 2; i <= Math.sqrt(num); i++) {
            if (num % i == 0) {
               return  false;
            }
        }

        return true;

    }
}
